﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FineUI;
using OnlineTestBLL;
using OnlineTestModel;

namespace OnlineTestUI.BackManager
{
    public partial class updateteacher : System.Web.UI.Page
    {
        TeachersBLL tb = new TeachersBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["id"]))
                {
                    int id = Convert.ToInt32(Request.QueryString["id"]);
                    Teachers oldt = new Teachers();
                    oldt = tb.GetModel(id);
                    tbRealName.Text = oldt.RealName;
                    tbUserName.Text = oldt.UserName;
                    tbPassWord.Text = oldt.PassWord;

                    tbDescription.Text = oldt.Description;
                    tbRoleId.Text = oldt.RoleId.ToString();
                    tbRoleList.Text = oldt.RoleList;
                    lCreateTime.Text = oldt.CreateTime.ToString("d");

                }
            }
        }
        protected void BtAdd_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["id"]))
            {
                Teachers t = new Teachers();
                t.Id = Convert.ToInt32(Request.QueryString["id"]);
                t.RealName = tbRealName.Text;
                t.UserName = tbUserName.Text;
                t.PassWord = tbPassWord.Text;
                t.Description = tbDescription.Text;
                t.RoleId = Convert.ToInt32(tbRoleId.Text);
                t.RoleList = tbRoleList.Text;
                //s.CreateId = ((Teachers)Session["teacher"]).Id;
                t.LastLoginTime = null;
                bool result = tb.Update(t);
                if (result)
                {
                    PageContext.Redirect("teacherlist.aspx", "_self");
                }
            }
        }
    }
}